;; open headers in c++ mode
(setq auto-mode-alist
      (append '(("\\.h$" . c++-mode)) auto-mode-alist))

(defun my-c-mode-common-hook()
  (c-set-offset 'brace-list-open 0)
  (highlight-symbol-mode)

  (setq
   c-default-style "bsd"
   c-basic-offset 2 ;; indent 2 spaces
   tab-width 2 ;; a tab equas 2 spaces
   indent-tabs-mode nil ;; insert spaces other than tabs
   )

  ;; hungry-delete and disable auto-newline
  (c-toggle-auto-hungry-state 1)
  (c-toggle-auto-newline 0)

  (define-key c-mode-base-map [(control \')] 'hs-toggle-hiding)
  (define-key c-mode-base-map [(return)] 'newline-and-indent)
  (define-key c-mode-base-map [M-f12] 'eassist-switch-h-cpp)

  (hs-minor-mode)
  (define-key c-mode-base-map [f1] 'hs-toggle-hiding)

  (highlight-symbol-mode t)
  )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(add-hook 'c++-mode-common-hook 'my-c-mode-common-hook)


;; switch source and header file
(require 'eassist nil 'noerror)